package com.hzcx.app.simplechat.ui.mine;

import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseActivity;
import com.hzcx.app.simplechat.bean.UpLoadImgBean;
import com.hzcx.app.simplechat.event.EditUserInfoEvent;
import com.hzcx.app.simplechat.ui.mine.contract.EditUserInfoContract;
import com.hzcx.app.simplechat.ui.mine.presenter.EditUserInfoPresenter;
import com.hzcx.app.simplechat.ui.user.bean.CityListBean;
import com.hzcx.app.simplechat.ui.user.bean.UserInfoBean;
import com.hzcx.app.simplechat.util.UserInfoUtil;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

import butterknife.BindView;

/**
 * 修改个性签名界面
 */
public class EditUserSignActivity extends BaseActivity<EditUserInfoPresenter> implements EditUserInfoContract.View {

    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.iv_title_right)
    ImageView ivTitleRight;
    @BindView(R.id.tv_title_right)
    TextView tvTitleRight;
    @BindView(R.id.et_sign)
    EditText etSign;

    private UserInfoBean userInfoBean;

    @Override
    public int getLayout() {
        return R.layout.activity_edit_sign;
    }

    @Override
    public void initPresenter() {
        mPresenter = new EditUserInfoPresenter();
    }

    @Override
    public void initView() {
        tvTitle.setText("个性签名");
        tvTitleRight.setText("完成");

        etSign.setText(UserInfoUtil.getUserSign());
    }

    @Override
    public void initData() {

        userInfoBean = UserInfoUtil.getUserInfo();

        tvTitleRight.setOnClickListener(view -> {
            userInfoBean.setBio(etSign.getText().toString());
            mPresenter.editUser(EditUserSignActivity.this, userInfoBean);
        });

    }

    @Override
    public void editSuccess() {
        EventBus.getDefault().post(new EditUserInfoEvent(EditUserInfoEvent.TAG_SIGN, etSign.getText().toString()));
        finish();
    }

    @Override
    public void upLoadResult(UpLoadImgBean data) {

    }

    @Override
    public void editFail() {

    }

    @Override
    public void cityListResult(List<CityListBean> data) {

    }
}
